home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group96a.txt
/
000131_icon-group-sender _Mon Jun 10 17:45:25 1996.msg
< prev
next >
Wrap
Internet Message Format
|
1996-09-05
|
2KB
Received: by cheltenham.cs.arizona.edu; Tue, 11 Jun 1996 07:45:48 MST
To: icon-group@cs.arizona.edu
Date: Mon, 10 Jun 1996 17:45:25 GMT
From: pardoej@lonnds.ml.com (Julian Pardoe LADS LDN X1428)
Message-Id: <DsspBq.M1s@tigadmin.ml.com>
Organization: Merrill Lynch Europe
Sender: icon-group-request@cs.arizona.edu
References: <Dsqq4z.AsA@eskimo.com>
Reply-To: pardoej@lonnds.ml.com
Subject: Re: m3 should have SWAP(a,b)
Errors-To: icon-group-errors@cs.arizona.edu
Status: O
In article <Dsqq4z.AsA@eskimo.com>, leeo@eskimo.com (Lee Odegard) writes:
-->dave@CS.Arizona.EDU (Dave Schaumann) writes:
-->
-->>As you say. For my part, the only time I've found 'swap' to be a useful
-->>operation is when I am writing sort algorithm (or sort-related algorithms,
-->>like heap manipulation).
-->
-->In my own work, I've seen many instances where algorithms could be described
-->more succintly with
--> designator := expr_designator := expression ;
-->to abbreviate
--> designator := expr_designator ;
--> expr_designator := expression ;
-->In this notation, a swap would appear
-->
--> VAR temp : type_of_designator ; BEGIN
--> temp := item1 := item2 := temp ; END ;
-->--Lee
This notation might confuse programmers used to right-associative assigment,
where
a := b := c
abbreviates
b := c; a :=b
Algol68C had the `displacement operator', :=:= which yield the old value of the
LHS rather than the new value (as yielded by :=). Thus a swap could be written
a := b :=:= a
This also gave us the equivalent of C's i++:
i +:=:= 1
and some neat syntax for list operations:
next OF new item := list head :=:= new item
Whether you like such things is a matter of taste. I did because it meant I could
expression a logically single operation as one statement (or `unit' in A68C-talk).
Likewise, (assuming a C-like stdio library):
fclose (file :=:= NULL)
meaning "close the file and note that we have no open file" as a single operation.
Of course, you can write some pretty bizarre stuff if you want to. My favourite
was
( b | x +:= 1; y | x ) +:= 1
-- jP --